<?php

/**
 * statement actions.
 *
 * @package    LYPO
 * @subpackage statement
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 2288 2006-10-02 15:22:13Z fabien $
 */
class statementActions extends autostatementActions
{

	protected function saveLypoStatement($lypo_statement)
	{
		parent::saveLypoStatement($lypo_statement);
		//Nu de thumbnail opslaan!
		/* @var $req sfWebRequest */
		$req = $this->getRequest();
		if($req->getFile('thumbnail') && !$req->hasFileError('thumbnail')){
			$file = $req->getFile('thumbnail');
			$img = new sfImage($file['tmp_name'], $file['type'], 'GD');
			$img->thumbnail(100,75,'center')->saveAs($lypo_statement->getThumbnailPath(), 'image/jpg');
		}
	}

	public function executeRemovethumb(sfWebRequest $req){
		$this->forward404Unless($req->getParameter('id'),'No id given');
		/* @var $statement LypoStatement */
		$statement = LypoStatementPeer::retrieveByPK($req->getParameter('id'));
		$this->forward404Unless($statement,'Statement not found');
		try {
			$statement->removeThumbnail();
			$this->getUser()->setFlash("message","Thumbnail is verwijderd");
		} catch (sfException $e){
			$this->getUser()->setFlash("message",$e->getMessage());
		}
		$this->forward('statement','edit');
	}
	
}
